﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utils.Extention;
#region Version Info
/* ========================================================================
* 【本页面功能概述】
*
* 作者：wangjianfeng 创建时间：2012/9/20 22:25:41
* 文件名：Pictrue.cs
*
* 修改者： 时间：
* 修改说明：
* ========================================================================
*/
#endregion
namespace ChinaLeg.Web.news
{
    public partial class Pictrue : System.Web.UI.Page
    {
        protected string title, description, keyWrods, bgImage, adScroll;

        protected int catid;
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!this.IsPostBack)
            {
                if (!Request.QueryString["id"].IsNullOrEmpty())
                {
                    int id = Request.QueryString["id"].ToInt32();
                    catid = id;
                    hlCat.Text = hlCat2.Text = ChinaLeg.Cache.Category.Instance.GetCatName(catid);
                    hlCat.NavigateUrl = hlCat2.NavigateUrl = Lib.WebLinks.GetCasePictrue(catid);

                        int pageid = ChinaLeg.BLL.CategoryPage.Instance.GetId(catid);
                        if (pageid > 0)
                        {
                            ChinaLeg.Model.CategoryPage model = ChinaLeg.BLL.CategoryPage.Instance.GetModel(pageid);
                            if (model != null)
                            {
                                litTitle.Text = hlCat.Text;
                                litContent.Text = model.Content;
                                
                            }
                        }

                        

                        int parentcatid = ChinaLeg.Cache.Category.Instance.GetParentId(catid);

                        hlParent.Text = hlParent2.Text = ChinaLeg.Cache.Category.Instance.GetCatName(parentcatid);
                        hlParent.NavigateUrl = hlParent2.NavigateUrl = Lib.WebLinks.GetCatLinks(parentcatid);

                        

                        

                        ChinaLeg.Cache.Category.Instance.GetModel(parentcatid, out title, out  keyWrods, out  description, out  bgImage);
                        Top1.CatId = parentcatid;
                        Top1.BgImage = bgImage;

                        string ids = ChinaLeg.Cache.Category.Instance.GetChildLevelIds(parentcatid);
                        rptRelation.DataSource = ChinaLeg.BLL.News.Instance.GetList(" and catid in (" + ids +") ", 15, "MidifyTime", 1);
                        rptRelation.DataBind();

                        rptCommend.DataSource = ChinaLeg.BLL.News.Instance.GetList(" and IndexCommend=1 ", 15, "MidifyTime", 0);
                        rptCommend.DataBind();

                    }
                    else
                    {
                        Response.Redirect("/");
                    }

                
            }
        }
    }
}